// 获取频道列表封装

import { useEffect, useState } from 'react'
import { getChannelAPI } from '@/apis/aryicle'

function useChannel() {
  // 1.获取频道列表所有逻辑
  const [channelList, setChannelList] = useState([])
  useEffect(() => {
    // 1.封装函数调用接口
    const getChannelList = async () => {
      const res = await getChannelAPI()
      setChannelList(res.data.channels)
    }
    // 2.调用函数
    getChannelList()

  }, [])
  // 2.导出组件中要用的数据
  return {
    channelList
  }
}



export {useChannel}